﻿using AutoMapper;
using Pay.DTO;
using Pay.IService;
using Pay.Core;
using Pay.Data;
using System;

namespace Pay.Service.AutoMapper {
	public class UserFeedBackMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public UserFeedBackMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
            _cfg.CreateMap<user_feedback_dto, UserFeedBack>()
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.createtime.ToUnix()))
                .ForMember(dest => dest.Merchant, src => src.MapFrom(c => c.merchant))
                .ForMember(dest => dest.UserContact, src => src.MapFrom(c => c.usercontact))
                .ForMember(dest => dest.UserFeedBackContent, src => src.MapFrom(c => c.user_feedback_content))
                .ForMember(dest => dest.UserId, src => src.MapFrom(c => c.userid))
                .ForMember(dest => dest.ReplyTitle, src => src.MapFrom(c => c.reply_title))
                .ForMember(dest => dest.ReplyContent, src => src.MapFrom(c => c.reply_content))
                .ForMember(dest => dest.ReplyTime, src => src.MapFrom(c => (c.reply_time == null ? (long?)null : ((DateTime)c.reply_time).ToUnix())))
                .ForMember(dest => dest.ReplyUserMobile, src => src.MapFrom(c => c.reply_user_mobile));

            _cfg.CreateMap<UserFeedBack, user_feedback_dto>()
				.ForMember(dest => dest.createtime, src => src.MapFrom(c => c.CreateTime.ToDateTime()))
				.ForMember(dest => dest.merchant, src => src.MapFrom(c => c.Merchant))
				.ForMember(dest => dest.usercontact, src => src.MapFrom(c => c.UserContact))
				.ForMember(dest => dest.user_feedback_content, src => src.MapFrom(c => c.UserFeedBackContent))
                .ForMember(dest => dest.userid, src => src.MapFrom(c => c.UserId))
                .ForMember(dest => dest.reply_title, src => src.MapFrom(c => c.ReplyTitle))
                .ForMember(dest => dest.reply_content, src => src.MapFrom(c => c.ReplyContent))
                .ForMember(dest => dest.reply_time, src => src.MapFrom(c => (c.ReplyTime == null ? (DateTime?)null : ((long)c.ReplyTime).ToDateTime())))
                .ForMember(dest => dest.reply_user_mobile, src => src.MapFrom(c => c.ReplyUserMobile));
        }
	}
}
